home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
10828
/
10828.xpi
/
chrome
/
content
/
newtabking-options.js
< prev
next >
Wrap
Text File
|
2010-02-10
|
28KB
|
787 lines
window.onload = loadPrefs;
function loadShortcuts(shortcutsList) {
var listy = document.getElementById('shortcutsListChildren');
if ( listy.hasChildNodes() ){
while ( listy.childNodes.length >= 1 ) { listy.removeChild( listy.firstChild ); }
}
var shortcutsItems, listitem, shortcutName, shortcutPath, shortcutIcon;
for (var i=0;i<shortcutsList.length;i++) {
if (shortcutsList[i]=='') continue;
shortcutsItems = shortcutsList[i].split('::');
if (shortcutsItems[0] == '' || shortcutsItems[0] == null || shortcutsItems[1] == '' || shortcutsItems[1] == null) continue;
addToShortcutsList(shortcutsItems[1], shortcutsItems[0], shortcutsItems[2]);
}
}
function loadPrefs() {
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService).getBranch(null);
// General
var ntkFocus = false;
try {
ntkFocus = prefs.getBoolPref("extensions.ntk.ntkfocus-pref");
} catch (e) {
prefs.setBoolPref("extensions.ntk.ntkfocus-pref", false);
}
if (ntkFocus ) {
document.getElementById('autoFocus-Pref').checked = 'true';
} else {
document.getElementById('autoFocus-Pref').checked = '';
}
var ntkInNewWindow = false;
try {
ntkInNewWindow = prefs.getBoolPref("extensions.ntk.loadInNewWindow-pref");
} catch (e) {
prefs.setBoolPref("extensions.ntk.loadInNewWindow-pref", false);
}
if (ntkInNewWindow ) {
document.getElementById('loadInNewWindow-Pref').checked = 'true';
} else {
document.getElementById('loadInNewWindow-Pref').checked = '';
}
var ntkInNewTab = false;
try {
ntkInNewTab = prefs.getBoolPref("extensions.ntk.loadInNewTab-pref");
} catch (e) {
prefs.setBoolPref("extensions.ntk.loadInNewTab-pref", false);
}
if (ntkInNewTab ) {
document.getElementById('loadInNewTab-Pref').checked = 'true';
} else {
document.getElementById('loadInNewTab-Pref').checked = '';
}
var mostUsedinNewTab = false;
try {
mostUsedinNewTab = prefs.getBoolPref("extensions.ntk.mostUsedinNewTab-pref");
} catch (e) {
prefs.setBoolPref("extensions.ntk.mostUsedinNewTab-pref", false);
}
if (mostUsedinNewTab ) {
document.getElementById('mostUsedinNewTab-Pref').checked = 'true';
} else {
document.getElementById('mostUsedinNewTab-Pref').checked = '';
}
var toolbarButton = false;
try {
toolbarButton = prefs.getBoolPref("extensions.ntk.ntkToolbar-pref");
} catch (e) {
prefs.setBoolPref("extensions.ntk.ntkToolbar-pref", false);
}
if (toolbarButton ) {
document.getElementById('ntkToolbar-pref').checked = 'true';
} else {
document.getElementById('ntkToolbar-pref').checked = '';
}
var statusbarButton = true;
try {
statusbarButton = prefs.getBoolPref("extensions.ntk.ntkStatusbar-pref");
} catch (e) {
prefs.setBoolPref("extensions.ntk.ntkStatusbar-pref", true);
}
if (statusbarButton ) {
document.getElementById('ntkStatusbar-pref').checked = 'true';
} else {
document.getElementById('ntkStatusbar-pref').checked = '';
}
var tips = 1;
try {
tips = prefs.getIntPref("extensions.ntk.ntkTip");
} catch (e) {
prefs.setIntPref("extensions.ntk.ntkTip", 1);
}
if (tips>0 ) {
document.getElementById('ntkTip-pref').checked = 'true';
} else {
document.getElementById('ntkTip-pref').checked = '';
}
var sharing = true;
try {
sharing = prefs.getBoolPref("extensions.ntk.ntkSharing");
} catch (e) {
prefs.setBoolPref("extensions.ntk.ntkSharing", true);
}
if (sharing) {
document.getElementById('sharing-pref').checked = 'true';
} else {
document.getElementById('sharing-pref').checked = '';
}
var headerAndSearch = true;
try {
headerAndSearch = prefs.getBoolPref("extensions.ntk.ntkHeaderSearch");
} catch (e) {
prefs.setBoolPref("extensions.ntk.ntkHeaderSearch", true);
}
if (headerAndSearch ) {
document.getElementById('ntkHeaderSearch-pref').checked = 'true';
} else {
document.getElementById('ntkHeaderSearch-pref').checked = '';
}
var ntkTabPerf = true;
try {
ntkTabPerf = prefs.getBoolPref("extensions.ntk.ntkTabPerfOn-pref");
} catch (e) {
prefs.setBoolPref("extensions.ntk.ntkTabPerfOn-pref", true);
}
if (ntkTabPerf ) {
document.getElementById('ntkTabPerfOn-pref').checked = 'true';
} else {
document.getElementById('ntkTabPerfOn-pref').checked = '';
}
var themes = true;
try {
themes = prefs.getBoolPref("extensions.ntk.ntkThemes");
} catch (e) {
prefs.setBoolPref("extensions.ntk.ntkThemes", true);
}
if (themes ) {
document.getElementById('themes-pref').checked = 'true';
} else {
document.getElementById('themes-pref').checked = '';
}
var clipboard = true;
clipboard = prefs.getBoolPref("extensions.ntk.ntkClipboard");
if (clipboard ) {
document.getElementById('ntkClipboard-pref').checked = 'true';
} else {
document.getElementById('ntkClipboard-pref').checked = '';
}
var searchEngine = 4;
try {
searchEngine = prefs.getIntPref("extensions.ntk.ntksearchEngine-pref");
} catch (e) {
prefs.setIntPref("extensions.ntk.ntksearchEngine-pref", 4);
}
document.getElementById('NTKSearchEngine-pref').selectedIndex = searchEngine ;
var titleStr = '(click to customize!)';
try {
titleStr = prefs.getComplexValue("extensions.ntk.titleStr", Components.interfaces.nsISupportsString).data;
} catch (e) {
titleStr = '(Click here to change!)';
}
document.getElementById('ntkTitleStr-Pref').value = titleStr;
var tabTitleStr = 'New Tab King';
try {
tabTitleStr = prefs.getComplexValue("extensions.ntk.tabTitleStr", Components.interfaces.nsISupportsString).data;
} catch (e) { }
document.getElementById('ntkTitleTabStr-Pref').value = tabTitleStr ;
// Background prefs
try {
var backgroundFILE = prefs.getComplexValue("extensions.ntk.backgroundFILE", Components.interfaces.nsISupportsString).data;
backgroundFILE = backgroundFILE.replace('file://', '');
} catch (e) {
var backgroundFILE = '';
}
try {
var backgroundRepeat = prefs.getIntPref("extensions.ntk.backgroundRepeat");
} catch (e) {
var backgroundRepeat =0;
}
try {
var backgroundColor = prefs.getCharPref("extensions.ntk.backgroundColor");
} catch (e) {
var backgroundColor ='eaeaea';
}
if (backgroundFILE == '') {
document.getElementById('enableBackground-Pref').checked = '';
document.getElementById('backgroundBrowseButton').disabled="true";
document.getElementById('backgroundPath-Pref').disabled="true";
document.getElementById('backgroundRepeat-Pref').disabled="true";
document.getElementById('backgroundColor-Pref').disabled="true";
} else {
document.getElementById('enableBackground-Pref').checked = 'true';
document.getElementById('backgroundBrowseButton').disabled="";
document.getElementById('backgroundPath-Pref').disabled="";
document.getElementById('backgroundRepeat-Pref').disabled="";
document.getElementById('backgroundColor-Pref').disabled="";
}
document.getElementById('backgroundPath-Pref').value = backgroundFILE;
document.getElementById('backgroundRepeat-Pref').value = backgroundRepeat ;
document.getElementById('backgroundColor-Pref').value = backgroundColor ;
// Most used websites prefs
try {
var blackListString = prefs.getCharPref("extensions.ntk.blacklist");
var blacklist = blackListString.split(';');
for (var i=0;i<blacklist.length;i++) {
if (blacklist[i]=='') continue;
addExceptionItem('blacklist-Pref', blacklist[i]);
}
} catch(e) {
}
// black tab list prefs
try {
var blackListString = prefs.getCharPref("extensions.ntk.blackTablist");
var blacklist = blackListString.split(';');
for (var i=0;i<blacklist.length;i++) {
if (blacklist[i]=='') continue;
addExceptionItem('blacklistTabs-Pref', blacklist[i]);
}
} catch(e) {
}
// Suggested sites
var suggestedOn = true;
try {
suggestedOn = prefs.getBoolPref("extensions.ntk.suggested-pref");
} catch (e){
prefs.setBoolPref("extensions.ntk.suggested-pref", true);
}
if (suggestedOn) {
document.getElementById('enableSuggested-Pref').checked = 'true';
} else {
document.getElementById('enableSuggested-Pref').checked = '';
}
// Shortcuts
var shortcutsOn = true;
try {
shortcutsOn = prefs.getBoolPref("extensions.ntk.shortcuts-pref");
} catch (e){
prefs.setBoolPref("extensions.ntk.shortcuts-pref", true);
}
if (shortcutsOn) {
document.getElementById('enableShortcuts-Pref').checked = 'true';
document.getElementById('shortcutsList').disabled="";
document.getElementById('removeShortcutsID').disabled="";
document.getElementById('addShortcutName-Pref').disabled="";
document.getElementById('shortcutPathBtnID').disabled="";
document.getElementById('shortcutIconPathBtnID').disabled="";
document.getElementById('shortcutAddBtn').disabled="";
} else {
document.getElementById('enableShortcuts-Pref').checked = '';
document.getElementById('shortcutsList').disabled="true";
document.getElementById('removeShortcutsID').disabled="true";
document.getElementById('addShortcutName-Pref').disabled="true";
document.getElementById('shortcutPathBtnID').disabled="true";
document.getElementById('shortcutIconPathBtnID').disabled="true";
document.getElementById('shortcutAddBtn').disabled="true";
}
var shortcutsStr = prefs.getComplexValue("extensions.ntk.shortcuts", Components.interfaces.nsISupportsString).data;
loadShortcuts( shortcutsStr.split(';') );
// Search Shortcuts
var searchShortcutsStr = prefs.getComplexValue("extensions.ntk.searchShortcuts", Components.interfaces.nsISupportsString).data;
var searchShortcutsList = searchShortcutsStr.split(';');
var searchShortcutsItems, searchListitem, searchShortcutName, searchShortcutPath;
for (var i=0;i<searchShortcutsList.length;i++) {
if (searchShortcutsList[i]=='') continue;
searchShortcutsItems = searchShortcutsList[i].split('::');
if (searchShortcutsItems[0] == '' || searchShortcutsItems[0] == null || searchShortcutsItems[1] == '' || searchShortcutsItems[1] == null) continue;
addToSearchShortcutsList(searchShortcutsItems[1], searchShortcutsItems[0]);
}
// Maxes
var maxMostUsed = prefs.getIntPref("extensions.ntk.maxMostUsedSites");
var maxRecentTabs= prefs.getIntPref("extensions.ntk.maxRecentClosedTabs");
document.getElementById('maxMostUsed-Pref').value = maxMostUsed;
document.getElementById('maxRecentlyClosedTabs-Pref').value = maxRecentTabs;
}
function savePrefs() {
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService).getBranch(null);
// General
var ntkFocus = document.getElementById('autoFocus-Pref').checked;
prefs.setBoolPref("extensions.ntk.ntkfocus-pref", ntkFocus );
var ntkinNewWindow = document.getElementById('loadInNewWindow-Pref').checked;
prefs.setBoolPref("extensions.ntk.loadInNewWindow-pref", ntkinNewWindow );
if (ntkinNewWindow) prefs.setIntPref("browser.startup.page", 0);
var ntkinNewTab = document.getElementById('loadInNewTab-Pref').checked;
prefs.setBoolPref("extensions.ntk.loadInNewTab-pref", ntkinNewTab );
var mostUsedinNewTab= document.getElementById('mostUsedinNewTab-Pref').checked;
prefs.setBoolPref("extensions.ntk.mostUsedinNewTab-pref", mostUsedinNewTab);
var toolbarButton= document.getElementById('ntkToolbar-pref').checked;
prefs.setBoolPref("extensions.ntk.ntkToolbar-pref", toolbarButton);
var statusbarButton= document.getElementById('ntkStatusbar-pref').checked;
prefs.setBoolPref("extensions.ntk.ntkStatusbar-pref", statusbarButton);
var sharing= document.getElementById('sharing-pref').checked;
prefs.setBoolPref("extensions.ntk.ntkSharing", sharing);
var headerAndSearch= document.getElementById('ntkHeaderSearch-pref').checked;
prefs.setBoolPref("extensions.ntk.ntkHeaderSearch", headerAndSearch);
var ntkPerf= document.getElementById('ntkTabPerfOn-pref').checked;
prefs.setBoolPref("extensions.ntk.ntkTabPerfOn-pref", ntkPerf);
var themes= document.getElementById('themes-pref').checked;
prefs.setBoolPref("extensions.ntk.ntkThemes", themes);
var tips= document.getElementById('ntkTip-pref').checked;
if (tips) {
prefs.setIntPref("extensions.ntk.ntkTip", 1);
} else {
prefs.setIntPref("extensions.ntk.ntkTip", 0);
}
var clipboard= document.getElementById('ntkClipboard-pref').checked;
prefs.setBoolPref("extensions.ntk.ntkClipboard", clipboard);
var ntkSearchEngine = document.getElementById('NTKSearchEngine-pref').selectedIndex ;
prefs.setIntPref("extensions.ntk.ntksearchEngine-pref", ntkSearchEngine );
var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
str.data = document.getElementById('ntkTitleStr-Pref').value;
prefs.setComplexValue("extensions.ntk.titleStr", Components.interfaces.nsISupportsString, str);
var str2 = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
str2.data = document.getElementById('ntkTitleTabStr-Pref').value;
prefs.setComplexValue("extensions.ntk.tabTitleStr", Components.interfaces.nsISupportsString, str2);
// Background prefs
var backImg = '', backRepeat =0, backColor='eaeaea';
if (document.getElementById('enableBackground-Pref').checked == true) {
backImg = document.getElementById('backgroundPath-Pref').value;
backRepeat = document.getElementById('backgroundRepeat-Pref').value;
backColor = document.getElementById('backgroundColor-Pref').value;
}
var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
if (backImg != '' ) str.data = 'file://' + backImg;
prefs.setComplexValue("extensions.ntk.backgroundFILE", Components.interfaces.nsISupportsString, str);
prefs.setIntPref("extensions.ntk.backgroundRepeat", backRepeat);
prefs.setCharPref("extensions.ntk.backgroundColor", backColor);
var MY_ID = "{FC5BAC7D-D696-4ba6-B913-CF8F000C33DF}";
var em = Components.classes["@mozilla.org/extensions/manager;1"].
getService(Components.interfaces.nsIExtensionManager);
var fileX = em.getInstallLocation(MY_ID).getItemFile(MY_ID, "chrome/content/themes/background.css");
var NTK_out = fileX.path;
var fileOut = Components.classes["@mozilla.org/file/local;1"].
createInstance(Components.interfaces.nsILocalFile);
fileOut.initWithPath(NTK_out);
var foStream = Components.classes["@mozilla.org/network/file-output-stream;1"].
createInstance(Components.interfaces.nsIFileOutputStream);
foStream.init(fileOut, 0x02 | 0x08 | 0x20, -1, 0); // 666
var charset = "UTF-8"; // Can be any character encoding name that Mozilla supports
var os = Components.classes["@mozilla.org/intl/converter-output-stream;1"]
.createInstance(Components.interfaces.nsIConverterOutputStream);
// This assumes that foStreamis the nsIOutputStream you want to write to
os.init(foStream, charset, 0, 0x0000);
var data =' ';
if (backImg!='') {
data = 'div#background {background-image: url(\'file://'+backImg+'\'); background-repeat:';
if (backRepeat==0) data += 'repeat-x';
if (backRepeat==1) data += 'repeat-y';
if (backRepeat==2) data += 'repeat';
if (backRepeat==3) data += 'no-repeat';
data += '; }div#mainStuff{ opacity:0.85 }';
}
os.writeString(data);
os.close();
foStream.close();
// Most used websites prefs
var blackListString = getExceptionList('blacklist-Pref');
prefs.setCharPref("extensions.ntk.blacklist", blackListString);
// black tab list prefs
var blackListTabString = getExceptionList('blacklistTabs-Pref');
prefs.setCharPref("extensions.ntk.blackTablist", blackListTabString);
// Maxes
var maxMostUsed =document.getElementById('maxMostUsed-Pref').value;
var maxRecentTabs=document.getElementById('maxRecentlyClosedTabs-Pref').value;
prefs.setIntPref("extensions.ntk.maxMostUsedSites", maxMostUsed );
prefs.setIntPref("extensions.ntk.maxRecentClosedTabs", maxRecentTabs);
// Suggested sites
var suggestedOff = document.getElementById('enableSuggested-Pref').checked;
prefs.setBoolPref("extensions.ntk.suggested-pref", suggestedOff );
// Shortcuts
var shortcutsOff = document.getElementById('enableShortcuts-Pref').checked;
prefs.setBoolPref("extensions.ntk.shortcuts-pref", shortcutsOff );
var shorty = getShortcuts();
var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
str.data = shorty;
prefs.setComplexValue("extensions.ntk.shortcuts", Components.interfaces.nsISupportsString, str);
// Search Shortcuts
var searchShorty = getSearchShortcuts();
var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
str.data = searchShorty ;
prefs.setComplexValue("extensions.ntk.searchShortcuts", Components.interfaces.nsISupportsString, str);
try {
window.arguments[1]();
} catch (e) {
}
window.close();
}
function getExceptionList(listID) {
var listy = document.getElementById(listID);
var i=0;
var item;
var outStr='';
while (item = listy.getItemAtIndex(i)) {
if (i > 0) outStr = outStr + ';';
outStr = outStr + item.getAttribute('label');
i++;
}
return outStr;
}
function addExceptionItem(listID, what) {
var listy = document.getElementById(listID);
var listitem = document.createElement('listitem');
listitem.setAttribute('label',what);
//listitem.setAttribute('type','checkbox');
listy.appendChild(listitem);
}
function addToSearchShortcutsList(name, path) {
var listy = document.getElementById('searchShortcutsListChildren');
var listitem = document.createElement('treeitem');
var treerow = document.createElement('treerow');
var shortcutName = document.createElement('treecell');
shortcutName.setAttribute('label', name);
treerow.appendChild(shortcutName);
var shortcutPath = document.createElement('treecell');
shortcutPath .setAttribute('label', path);
treerow.appendChild(shortcutPath );
listitem.appendChild(treerow);
listy.appendChild(listitem);
}
function addToShortcutsList(name, path, icon) {
var listy = document.getElementById('shortcutsListChildren');
var listitem = document.createElement('treeitem');
var treerow = document.createElement('treerow');
var shortcutName = document.createElement('treecell');
shortcutName.setAttribute('label', name);
treerow.appendChild(shortcutName);
var shortcutPath = document.createElement('treecell');
shortcutPath .setAttribute('label', path);
treerow.appendChild(shortcutPath );
var shortcutIcon = document.createElement('treecell');
if (icon == '' || icon == null) { icon = ' '; }
shortcutIcon.setAttribute('label', icon);
treerow.appendChild(shortcutIcon );
listitem.appendChild(treerow);
listy.appendChild(listitem);
/*
<treechildren>
<treeitem>
<treerow>
<treecell label="Feathers" />
<treecell label="Male" />
<treecell label="Tabby" />
</treerow>
</treeitem>
</treechildren>
*/
}
function browseLoc(returnID, showExtensionDir, isImage) {
const nsIFilePicker = Components.interfaces.nsIFilePicker;
var fp = Components.classes["@mozilla.org/filepicker;1"]
.createInstance(nsIFilePicker);
fp.init(window, "Select background image file", nsIFilePicker.modeOpen);
if (showExtensionDir) {
var MY_ID = "{FC5BAC7D-D696-4ba6-B913-CF8F000C33DF}";
var em = Components.classes["@mozilla.org/extensions/manager;1"].
getService(Components.interfaces.nsIExtensionManager);
// the path may use forward slash ("/") as the delimiter
// returns nsIFile for the extension's install.rdf
var fileY = em.getInstallLocation(MY_ID).getItemFile(MY_ID, "chrome/content/themes");
fp.displayDirectory = fileY;
}
if (isImage) {
fp.appendFilters( nsIFilePicker.filterAll | nsIFilePicker.filterImages);
} else {
fp.appendFilters( nsIFilePicker.filterAll);
}
var rv = fp.show();
if (rv == nsIFilePicker.returnOK || rv == nsIFilePicker.returnReplace) {
var file = fp.file;
var path = fp.file.path;
path = path.replace(/\\/g, '/');
// work with returned nsILocalFile...
document.getElementById(returnID).value = path;
}
}
function enableShortcuts() {
var enab = document.getElementById('enableShortcuts-Pref').checked;
if (!enab ) {
document.getElementById('shortcutsList').disabled="true";
document.getElementById('removeShortcutsID').disabled="true";
document.getElementById('addShortcutName-Pref').disabled="true";
document.getElementById('shortcutPathBtnID').disabled="true";
document.getElementById('shortcutIconPathBtnID').disabled="true";
document.getElementById('shortcutAddBtn').disabled="true";
} else {
document.getElementById('shortcutsList').disabled="";
document.getElementById('removeShortcutsID').disabled="";
document.getElementById('addShortcutName-Pref').disabled="";
document.getElementById('shortcutPathBtnID').disabled="";
document.getElementById('shortcutIconPathBtnID').disabled="";
document.getElementById('shortcutAddBtn').disabled="";
}
}
function enableBackground() {
var enab = document.getElementById('enableBackground-Pref').checked;
if (enab) {
document.getElementById('backgroundBrowseButton').disabled="";
// document.getElementById('backgroundPath-Pref').disabled="";
document.getElementById('backgroundRepeat-Pref').disabled="";
document.getElementById('backgroundColor-Pref').disabled="";
} else {
document.getElementById('backgroundBrowseButton').disabled="true";
document.getElementById('backgroundRepeat-Pref').disabled="true";
document.getElementById('backgroundColor-Pref').disabled="true";
}
}
function removeSelectedFromList(listID) {
var list = document.getElementById(listID);
var count = list.selectedCount;
while (count--){
var item = list.selectedItems[0];
list.removeItemAt(list.getIndexOfItem(item));
}
}
function AddSearchShortcutBtn() {
var path = document.getElementById('x1-Pref').value;
var name = document.getElementById('x2-Pref').value;
if (path == '' || name == '') return;
// path = path.replace(/\//g, '\\');
addToSearchShortcutsList(name, path);
document.getElementById('x1-Pref').value= '';
document.getElementById('x2-Pref').value= '';
}
function addShortcutBtn() {
var name = document.getElementById('addShortcutName-Pref').value;
var path = document.getElementById('addShortcutPath-Pref').value;
var icon = document.getElementById('addShortcutIcon-Pref').value;
if (path == '' || name == '') return;
path = path.replace(/\//g, '\\');
if (icon != '') { icon = 'file://'+icon; }
addToShortcutsList(name, path, icon);
document.getElementById('addShortcutName-Pref').value= '';
document.getElementById('addShortcutPath-Pref').value= '';
document.getElementById('addShortcutIcon-Pref').value = '';
}
function getSearchShortcuts() {
var tree = document.getElementById('searchShortcutsList');
tree.view.selection.rangedSelect(0,100,true);
var outStr = '';
var rangeCount = tree.view.selection.getRangeCount();
for(var i=0; i < rangeCount; i++) {
var start = {};
var end = {};
tree.view.selection.getRangeAt(i, start, end);
for(var c=start.value; c <= end.value; c++) {
try {
var selected = tree.view.getItemAtIndex(c);
if (outStr != '') outStr += ';';
var shortcutName = selected.firstChild.firstChild.getAttribute('label');
var shortcutPath = selected.firstChild.firstChild.nextSibling.getAttribute('label');
} catch (e) {
break;
}
outStr += shortcutPath + '::' + shortcutName;
}
}
return outStr;
}
function getShortcuts() {
var tree = document.getElementById('shortcutsList');
tree.view.selection.rangedSelect(0,100,true);
var outStr = '';
var rangeCount = tree.view.selection.getRangeCount();
for(var i=0; i < rangeCount; i++) {
var start = {};
var end = {};
tree.view.selection.getRangeAt(i, start, end);
for(var c=start.value; c <= end.value; c++) {
try {
var selected = tree.view.getItemAtIndex(c);
if (outStr != '') outStr += ';';
var shortcutName = selected.firstChild.firstChild.getAttribute('label');
var shortcutPath = selected.firstChild.firstChild.nextSibling.getAttribute('label');
var shortcutIcon = selected.firstChild.firstChild.nextSibling.nextSibling.getAttribute('label');
} catch (e) {
break;
}
outStr += shortcutPath + '::' + shortcutName;
if (shortcutIcon != '') outStr += '::' + shortcutIcon;
}
}
return outStr;
}
function moveUp(listID) {
var tree = document.getElementById(listID);
var rangeCount = tree.view.selection.getRangeCount();
var start = {};
var end = {};
tree.view.selection.getRangeAt(0, start, end);
if (start.value!=end.value) return;
var selected = tree.currentIndex;
if (selected==-1) return;
var shor = getShortcuts();
var shortcutsList = shor.split(';');
if (selected>0) {
var temp = shortcutsList[selected-1];
shortcutsList[selected-1] = shortcutsList[selected];
shortcutsList[selected] = temp;
loadShortcuts( shortcutsList );
tree.view.selection.select(selected-1);
}
}
function moveDown(listID) {
var tree = document.getElementById(listID);
var rangeCount = tree.view.selection.getRangeCount();
var start = {};
var end = {};
tree.view.selection.getRangeAt(0, start, end);
if (start.value!=end.value) return;
var selected = tree.currentIndex;
var shor = getShortcuts();
var shortcutsList = shor.split(';');
if (selected<shortcutsList.length-1) {
var temp = shortcutsList[selected+1];
shortcutsList[selected+1] = shortcutsList[selected];
shortcutsList[selected] = temp;
loadShortcuts( shortcutsList );
tree.view.selection.select(selected+1);
}
}
function removeSelectedFromTree(listID) {
var tree = document.getElementById(listID);
var rangeCount = tree.view.selection.getRangeCount();
var toDelArr = new Array();
var toDelArrI = 0;
for(var i=0; i < rangeCount; i++) {
var start = {};
var end = {};
tree.view.selection.getRangeAt(i, start, end);
for(var c=start.value; c <= end.value; c++) {
var selected = tree.view.getItemAtIndex(c);
toDelArr[toDelArrI] = selected;
toDelArrI++;
}
}
for (var i=0;i<toDelArr.length;i++) {
var parent = toDelArr[i].parentNode;
parent.removeChild(toDelArr[i]);
}
}
function newtabkingPrefwindowButtons(){
var platform = navigator.platform.toLowerCase();
var isWindows = ((platform.indexOf("win") != -1) ? true : false);
if(!isWindows){
try{
var buttonAccept=document.documentElement.getButton('accept');
buttonAccept.hidden = false;
buttonAccept.disabled = false;
}catch(e){;}
try{
document.getElementById("newtabkingAcceptBtn").hidden = false;
document.getElementById("newtabkingAcceptBtn").disabled = false;
}catch(e){;}
try{
document.getElementById("newtabkingAcceptBtn").hidden = false;
document.getElementById("newtabkingCancelBtn").hidden = false;
}catch(e){;}
}//if
return true;
}